package com.dchh.android.suverynew.presenter.impl;

import com.dchh.android.suverynew.module.local.ITableSelectMoudle;
import com.dchh.android.suverynew.module.local.impl.TableSelectMoudle;
import com.dchh.android.suverynew.presenter.ITableSelectPresenter;
import com.dchh.android.suverynew.view.ITaleSelectView;
import com.dhcc.android.base.common.bean.Table;
import com.dhcc.android.base.utils.Constants;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * Created by eric on 2016/8/13.
 */
public class TableSelectPresenter implements ITableSelectPresenter, TableSelectMoudle.TableSelectMoudleListener {
    private ITaleSelectView mTableSelectView;
    private ITableSelectMoudle mTableSelectMoudle;

    public TableSelectPresenter(ITaleSelectView mTableSelectView) {
        this.mTableSelectView = mTableSelectView;
        this.mTableSelectMoudle = new TableSelectMoudle(this);
    }

    @Override
    public void initData(InputStream is, String periodCode) {
        this.mTableSelectMoudle.initData(is, periodCode);
    }

    @Override
    public void restore() {

    }

    @Override
    public void getNodeList(String root, String code) {
        this.mTableSelectView.showProgressDialog("正在载入，请稍候...");
        this.mTableSelectMoudle.getNodeList(root, code);
    }

    @Override
    public void initYCDatas(String root, String tbid, String tblabel, String periodLabel) {
        this.mTableSelectMoudle.initYCDatas(root, tbid, tblabel, periodLabel, mTableSelectView.getContext());
    }

    @Override
    public void onInitData(List<Map<String, String>> list) {
        this.mTableSelectView.onInitData(list);
    }

    @Override
    public void restore(Table table) {
        this.mTableSelectView.onRestore(table);
    }

    @Override
    public void onNodeList(String code) {
        this.mTableSelectView.closeProgressDialog();
        this.mTableSelectView.onNodeList(code);
    }

    @Override
    public void onGoToActivity(String tbid, String tblabel) {

    }

    @Override
    public void onYCDataSeaching() {
        this.mTableSelectView.onYCDataSearching();
    }

    @Override
    public void onYCData(String tbid, String tblabel) {
        Constants.closeDialog();
        this.mTableSelectView.onYCData(tbid, tblabel);
    }

    @Override
    public void onYCDataEmpty() {
        Constants.closeDialog();
        this.mTableSelectView.onYCDataEmpty();
    }
}
